/***************************************************************
Made by: Cultured::Labs

Copyright (c) 2010 Cultured::Labs
****************************************************************/
#include <string>
#include "checkCharacter.h"

int checkCharacter(char input, std::string compare, std::string& add, std::string& shift) {
  int occurrence = 0;

  //checks whether the given character is valid
  for (unsigned int i = 0; i < compare.size(); i++) {
    if (compare[i] == input && add[i] == '-') {
      add[i] = compare[i];
      occurrence++;
    }
  }

  //adds misses if needed
  if (occurrence == 0) {
    for (unsigned int i = 0; i < shift.size(); i++) {
      if (shift[i] == input) {
        return occurrence;
      }
    }
    std::string temp(1, input);
    temp.append(", ");
    shift.append(temp);
  }
  return occurrence;
}
